| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import { connect as reduxConnect } from 'react-redux'; |
||
| 18 | const provideServices = (bottle, connect) => { |
||
| 19 | // Components |
||
| 20 | bottle.serviceFactory('ShortUrls', ShortUrls, 'SearchBar', 'ShortUrlsList'); |
||
| 21 | bottle.decorator('ShortUrls', reduxConnect( |
||
| 22 | (state) => assoc('shortUrlsList', state.shortUrlsList.shortUrls, state.shortUrlsList) |
||
| 23 | )); |
||
| 24 | |||
| 25 | bottle.serviceFactory('SearchBar', SearchBar, 'ColorGenerator'); |
||
| 26 | bottle.decorator('SearchBar', connect([ 'shortUrlsListParams' ], [ 'listShortUrls' ])); |
||
| 27 | |||
| 28 | bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsRow'); |
||
| 29 | bottle.decorator('ShortUrlsList', connect( |
||
| 30 | [ 'selectedServer', 'shortUrlsListParams' ], |
||
| 31 | [ 'listShortUrls', 'resetShortUrlParams' ] |
||
| 32 | )); |
||
| 33 | |||
| 34 | bottle.serviceFactory('ShortUrlsRow', ShortUrlsRow, 'ShortUrlsRowMenu', 'ColorGenerator', 'stateFlagTimeout'); |
||
| 35 | |||
| 36 | bottle.serviceFactory('ShortUrlsRowMenu', ShortUrlsRowMenu, 'DeleteShortUrlModal', 'EditTagsModal'); |
||
| 37 | bottle.serviceFactory('CreateShortUrlResult', CreateShortUrlResult, 'stateFlagTimeout'); |
||
| 38 | |||
| 39 | bottle.serviceFactory('CreateShortUrl', CreateShortUrl, 'TagsSelector', 'CreateShortUrlResult'); |
||
| 40 | bottle.decorator( |
||
| 41 | 'CreateShortUrl', |
||
| 42 | connect([ 'shortUrlCreationResult' ], [ 'createShortUrl', 'resetCreateShortUrl' ]) |
||
| 43 | ); |
||
| 44 | |||
| 45 | bottle.serviceFactory('DeleteShortUrlModal', () => DeleteShortUrlModal); |
||
| 46 | bottle.decorator('DeleteShortUrlModal', connect( |
||
| 47 | [ 'shortUrlDeletion' ], |
||
| 48 | [ 'deleteShortUrl', 'resetDeleteShortUrl', 'shortUrlDeleted' ] |
||
| 49 | )); |
||
| 50 | |||
| 51 | bottle.serviceFactory('EditTagsModal', EditTagsModal, 'TagsSelector'); |
||
| 52 | bottle.decorator('EditTagsModal', connect( |
||
| 53 | [ 'shortUrlTags' ], |
||
| 54 | [ 'editShortUrlTags', 'resetShortUrlsTags', 'shortUrlTagsEdited' ] |
||
| 55 | )); |
||
| 56 | |||
| 57 | // Actions |
||
| 58 | bottle.serviceFactory('editShortUrlTags', editShortUrlTags, 'buildShlinkApiClient'); |
||
| 59 | bottle.serviceFactory('resetShortUrlsTags', () => resetShortUrlsTags); |
||
| 60 | bottle.serviceFactory('shortUrlTagsEdited', () => shortUrlTagsEdited); |
||
| 61 | |||
| 62 | bottle.serviceFactory('listShortUrls', listShortUrls, 'buildShlinkApiClient'); |
||
| 63 | bottle.serviceFactory('resetShortUrlParams', () => resetShortUrlParams); |
||
| 64 | |||
| 65 | bottle.serviceFactory('createShortUrl', createShortUrl, 'buildShlinkApiClient'); |
||
| 66 | bottle.serviceFactory('resetCreateShortUrl', () => resetCreateShortUrl); |
||
| 67 | |||
| 68 | bottle.serviceFactory('deleteShortUrl', deleteShortUrl, 'buildShlinkApiClient'); |
||
| 69 | bottle.serviceFactory('resetDeleteShortUrl', () => resetDeleteShortUrl); |
||
| 70 | bottle.serviceFactory('shortUrlDeleted', () => shortUrlDeleted); |
||
| 71 | }; |
||
| 72 | |||
| 74 |